package com.jsoft.jsofted.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.diboot.core.binding.annotation.BindField;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IsNotNull;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.jsoft.jsofted.framework.entity.OfTenantEntity;
import com.jsoft.jsofted.framework.entity.TreeEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.List;

/**
 * 业务隶属树(业务参与者)：用来构建业务流程各环节参与者的上下级关系
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Table("sys_actor")
@TableName("sys_actor")
public class ActorEntity extends OfTenantEntity implements TreeEntity {

    @Column(length = 256)
    @IsNotNull
    protected String name;

    @Column(length = 32)
    protected Long parentId;

    @TableField(exist = false)
    @BindField(entity = ActorEntity.class, field = "name", condition = "parent_id=id")
    protected String parentName;

    /**
     * 节点类型：tree-业务树，org-机构节点，post-职位节点，user-人员节点
     */
    @Column(length = 8)
    @IsNotNull
    protected String type;

    @Column(length = 20, decimalLength = 6)
    @IsNotNull
    protected BigDecimal sortValue;

    /**
     * [{ id: ''，name: '' }, ... ]
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Column(type = MySqlTypeConstant.TEXT)
    protected List orgList;

    /**
     * 树形结构一级节点为单位，二级节点为职位
     * [{id:String, name:Strng, children:[]}, ... ]
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Column(type = MySqlTypeConstant.TEXT)
    protected List postList;

    /**
     * 用户ID：
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Column(type = MySqlTypeConstant.TEXT)
    protected List userList;

    /**
     * 排除项：可以在上述定义的基础上排除某些人
     * [{id: '', name: ''}, ...]
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Column(type = MySqlTypeConstant.TEXT)
    protected List excludes;
}
